// $Id: partitionizerhighlow.cpp 58 2004-10-20 11:05:39Z hansemil $
#include "partitionizerhighlow.h"
#include "distributions.h"
#include "node.h"

#include <stdlib.h>
#include <string.h>
#include <assert.h>

#include <iostream>
using namespace std;

/**
 * @todo Document this
 */
PartitionizerHighLow::PartitionizerHighLow()
{
	strcpy(m_names[0], "High");
	strcpy(m_names[1], "Low");
}

/**
 * Use this method to find out what partition a node belongs to.
 *
 * @param node A pointer to a node to find its partition.
 * @returns The partition index.
 */
int PartitionizerHighLow::getPartition(Node *node)
{
	if(node->getBandwidthUp() > Distributions::getInstance()->bandwidthUp(RAND_MAX/2)){
		return 0;
	}
	else{
		return 1;
	}
}

/**
 * Returns the number of partitions.
 *
 * @returns The number of partitions available.
 */
int PartitionizerHighLow::getPartitionCount()
{
	return 2;
}

/**
 * Find out a partitions name by sending its index as a parameter.
 *
 * @param index The index of the partition to get at name for.
 * @returns A string with a human readable partition name.
 */
char *PartitionizerHighLow::getPartitionName(int index)
{
	assert(index>=0 && index<2);
	return m_names[index];
}
